/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.uniminuto.edu.gimnasioInteligente.session;

import co.uniminuto.edu.gimnasioInteligente.entities.ProgramacionEvento;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author diegoalejandro
 */
@Stateless
public class ProgramacionEventoFacade extends AbstractFacade<ProgramacionEvento> {
    @PersistenceContext(unitName = "GimnasioInteligenteEJB_JSF-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public ProgramacionEventoFacade() {
        super(ProgramacionEvento.class);
    }
    
    public List<ProgramacionEvento> getEventosPorSede(int idSede){
          String queryString = "select t from ProgramacionEvento t where t.sedeidSede.idSede = "+ idSede +"";
        System.out.println("Query: " + queryString);
        Query query = getEntityManager().createQuery(queryString);
        List<ProgramacionEvento> results = query.getResultList();
        if (results != null && results.size() > 0) {
            return results;
        }
        return null;
    }
    
}
